package org.come.Jpanel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.util.ArrayList;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;

import org.come.bean.GoodsForGoodsBean;
import org.come.mouslisten.GoodsForGoodsChooseGetMouslisten;
import org.come.until.ScrollUI;

import com.tool.btn.FormsOnOffBtn;
import com.tool.btn.GoodsExchangeBtn;


public class GoodsExchangeJpanel  extends JPanel{
	private JScrollPane goodScrollPane1,// 物品列表滚动条
						goodScrollPane2;// 兑换材料列表滚动条
	private JTextArea srmc;//搜索输入框
	private GoodsExchangeBtn ssBtn,// 确认兑换
							 btnsurebuy,// 搜索按钮
							 qbBtn,//全部按钮
							 tzBtn,//套装按钮
							 cwBtn,//宠物按钮
							 xqBtn,//仙器按钮
							 zhBtn;//杂物按钮
   private java.util.List<GoodsForGoodsBean> goodgodbean;//物物兑换的bean	
   private GoodForGoodJpanel [] goodForGoodJpanel;//兑换物品面板
   private GoodsForDelGoodsJpanel goodsForDelGoodsJpanel;//消耗物品面板
  
	public GoodsExchangeJpanel() {
		// TODO Auto-generated constructor stub
	//	getBeanMes();
		// 键盘监听
				this.setPreferredSize(new Dimension(622, 486));
				this.setLayout(null);
				this.setBackground(Color.BLACK);
	}
	/**
	 * 进行init 面板布局
	 */
	public void initJlabel(){
		//查找物品框
		srmc=new JTextArea("");
		Font f = new Font("宋体",Font.PLAIN,16);
		srmc.setFont(f);
		srmc.setForeground(Color.yellow);
		srmc.setOpaque(false);
		srmc.setBounds(96, 40, 150, 18);
//		srmc.setBorder(BorderFactory.createLineBorder(Color.red));
		this.add(srmc);
		
		//搜索按钮
		ssBtn = new GoodsExchangeBtn("inkImg/hongmu/2/111.png", 1, "搜索", 1, this);
		ssBtn.setBounds(265, 38, 85, 24);
		this.add(ssBtn);
		//确认兑换按钮
		btnsurebuy = new GoodsExchangeBtn("inkImg/hongmu/2/111.png", 1, "确认兑换", 2, this);
		btnsurebuy.setBounds(475, 425, 85, 24);
		this.add(btnsurebuy);
		//全部按钮
		qbBtn = new GoodsExchangeBtn("inkImg/hongmu/2/112.png", 1, "全部", 3, this);
		qbBtn.setBounds(35, 65, 65, 24);
		this.add(qbBtn);
		//套装按钮
		tzBtn = new GoodsExchangeBtn("inkImg/hongmu/2/112.png", 1, "套装", 4, this);
		tzBtn.setBounds(105, 65, 65, 24);
		this.add(tzBtn);
		//宠物按钮
		cwBtn = new GoodsExchangeBtn("inkImg/hongmu/2/112.png", 1, "宠物", 5, this);
		cwBtn.setBounds(175, 65, 65, 24);
		this.add(cwBtn);
		//仙器按钮
		xqBtn = new GoodsExchangeBtn("inkImg/hongmu/2/112.png", 1, "仙器", 6, this);
		xqBtn.setBounds(245, 65,65, 24);
		this.add(xqBtn);
		//杂货按钮
		zhBtn = new GoodsExchangeBtn("inkImg/hongmu/2/112.png", 1, "杂货", 7, this);
		zhBtn.setBounds(315, 65, 65, 24);
		this.add(zhBtn);
		// 关闭按钮事件
		FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/hongmu/2/8_jpg.button.btn_close.jpg", 1, 90);
		offBtn.setBounds(600, 0, 23, 23);
		this.add(offBtn);
	}
	

	/**
	 * 展示兑换材料与物品数据
	 */
	public void initGoodsList(java.util.List<GoodsForGoodsBean> goodgodbean){
		initJlabel();//实例化面板
		this.goodgodbean=goodgodbean;
		//放置物品面板
		goodsForDelGoodsJpanel=new GoodsForDelGoodsJpanel(this);
//		//展示需要的物品信息	
		goodsForDelGoodsJpanel.setPreferredSize(new Dimension(180, 600));
//		//兑换材料滚动条  物品使用
		goodScrollPane2 = new JScrollPane();
		goodScrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		goodScrollPane2.getVerticalScrollBar().setUI(new ScrollUI());
		goodScrollPane2.getViewport().setOpaque(false);
		goodScrollPane2.setOpaque(false);
		goodScrollPane2.setBounds(420, 81, 180, 324);
		goodScrollPane2.setBorder(BorderFactory.createLineBorder(new Color(31, 7, 8)));
		goodScrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		goodScrollPane2.getViewport().add(goodsForDelGoodsJpanel);
		goodScrollPane2.validate();
		this.add(goodScrollPane2);
		JPanel jpa=new JPanel();
		jpa.setPreferredSize(new Dimension(160, 600));
		//jpa.setBorder(BorderFactory.createLineBorder(Color.blue));
		jpa.setOpaque(false);
		goodScrollPane1 = new JScrollPane();
		goodScrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		goodScrollPane1.getVerticalScrollBar().setUI(new ScrollUI());
		goodScrollPane1.getViewport().setOpaque(false);
		goodScrollPane1.setOpaque(false);
		goodScrollPane1.setBounds(26, 119, 384, 338);
		goodScrollPane1.setBorder(BorderFactory.createLineBorder(new Color(31, 7, 8)));
		goodScrollPane1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		goodScrollPane1.getViewport().add(jpa);
		goodScrollPane1.validate();
		goodForGoodJpanel=new GoodForGoodJpanel[goodgodbean.size()];
        for (int i = 0; i < goodgodbean.size(); i++) {
			goodForGoodJpanel[i]=new GoodForGoodJpanel(goodgodbean.get(i));
			goodForGoodJpanel[i].setPreferredSize(new Dimension(355, 40));
//			goodForGoodJpanel[i].setBorder(BorderFactory.createLineBorder(Color.blue));
			goodForGoodJpanel[i].addMouseListener(new GoodsForGoodsChooseGetMouslisten(goodForGoodJpanel,i,goodsForDelGoodsJpanel,goodgodbean.get(i)));
			jpa.add(goodForGoodJpanel[i]);	
		}
    	this.add(goodScrollPane1);
	}
//	/**
//	 * 架设bean 数据
//	 */
//	public void getBeanMes(){
//		
//		GoodsForGoodsBean god;
//		goodgodbean=new ArrayList<>();
//		for (int i = 2; i < 7; i++) {
//			god=new GoodsForGoodsBean();
//			god.setNameString("name"+i);
//			god.setItemid(i);
//			god.setDelte("204=1|205=1|206=1");
//			god.setGetGoods("204=1");
//			goodgodbean.add(god);
//		}
//
//	}
	
	/**
	 * 画背景
	 */
	@Override
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
		g.drawImage( new ImageIcon("inkImg/hongmu/2/11_png.xy2uiimg.cash_bg.png").getImage(), 0, 0, 622, 486, this);
	}
	
	public JScrollPane getgoodScrollPane1() {
		return goodScrollPane1;
	}

	public void setgoodScrollPane1(JScrollPane goodScrollPane1) {
		this.goodScrollPane1 = goodScrollPane1;
	}

	public JScrollPane getgoodScrollPane2() {
		return goodScrollPane2;
	}

	public void setgoodScrollPane2(JScrollPane goodScrollPane2) {
		this.goodScrollPane2 = goodScrollPane2;
	}
	
	public GoodsExchangeBtn getBtnsurebuy() {
		return btnsurebuy;
	}

	public void setBtnsurebuy(GoodsExchangeBtn btnsurebuy) {
		this.btnsurebuy = btnsurebuy;
	}
	
	public GoodsExchangeBtn getBtnssBtn() {
		return ssBtn;
	}

	public void setBtnss(GoodsExchangeBtn ssBtn) {
		this.ssBtn = ssBtn;
	}

	public GoodsExchangeBtn getBtnqbBtn() {
		return qbBtn;
	}

	public void setBtnqb(GoodsExchangeBtn qbBtn) {
		this.qbBtn = qbBtn;
	}
	
	public GoodsExchangeBtn getBtntzBtn() {
		return tzBtn;
	}

	public void setBtntz(GoodsExchangeBtn tzBtn) {
		this.tzBtn = tzBtn;
	}
	
	public GoodsExchangeBtn getBtncwBtn() {
		return cwBtn;
	}

	public void setBtncw(GoodsExchangeBtn cwBtn) {
		this.cwBtn = cwBtn;
	}
	
	public GoodsExchangeBtn getBtnxqBtn() {
		return xqBtn;
	}

	public void setBtnxq(GoodsExchangeBtn xqBtn) {
		this.xqBtn = xqBtn;
	}
	
	public GoodsExchangeBtn getBtnzhBtn() {
		return zhBtn;
	}

	public void setBtnzh(GoodsExchangeBtn zhBtn) {
		this.zhBtn = zhBtn;
	}
	public JScrollPane getGoodScrollPane1() {
	return goodScrollPane1;
}


public void setGoodScrollPane1(JScrollPane goodScrollPane1) {
	this.goodScrollPane1 = goodScrollPane1;
}


public JScrollPane getGoodScrollPane2() {
	return goodScrollPane2;
}


public void setGoodScrollPane2(JScrollPane goodScrollPane2) {
	this.goodScrollPane2 = goodScrollPane2;
}


public JTextArea getSrmc() {
	return srmc;
}


public void setSrmc(JTextArea srmc) {
	this.srmc = srmc;
}


public GoodsExchangeBtn getSsBtn() {
	return ssBtn;
}


public void setSsBtn(GoodsExchangeBtn ssBtn) {
	this.ssBtn = ssBtn;
}


public GoodsExchangeBtn getQbBtn() {
	return qbBtn;
}


public void setQbBtn(GoodsExchangeBtn qbBtn) {
	this.qbBtn = qbBtn;
}


public GoodsExchangeBtn getTzBtn() {
	return tzBtn;
}


public void setTzBtn(GoodsExchangeBtn tzBtn) {
	this.tzBtn = tzBtn;
}


public GoodsExchangeBtn getCwBtn() {
	return cwBtn;
}


public void setCwBtn(GoodsExchangeBtn cwBtn) {
	this.cwBtn = cwBtn;
}


public GoodsExchangeBtn getXqBtn() {
	return xqBtn;
}


public void setXqBtn(GoodsExchangeBtn xqBtn) {
	this.xqBtn = xqBtn;
}


public GoodsExchangeBtn getZhBtn() {
	return zhBtn;
}


public void setZhBtn(GoodsExchangeBtn zhBtn) {
	this.zhBtn = zhBtn;
}


public java.util.List<GoodsForGoodsBean> getGoodgodbean() {
	return goodgodbean;
}


public void setGoodgodbean(java.util.List<GoodsForGoodsBean> goodgodbean) {
	this.goodgodbean = goodgodbean;
}


public GoodForGoodJpanel[] getGoodForGoodJpanel() {
	return goodForGoodJpanel;
}


public void setGoodForGoodJpanel(GoodForGoodJpanel[] goodForGoodJpanel) {
	this.goodForGoodJpanel = goodForGoodJpanel;
}


public GoodsForDelGoodsJpanel getGoodsForDelGoodsJpanel() {
	return goodsForDelGoodsJpanel;
}


public void setGoodsForDelGoodsJpanel(
		GoodsForDelGoodsJpanel goodsForDelGoodsJpanel) {
	this.goodsForDelGoodsJpanel = goodsForDelGoodsJpanel;
}
	
}
